/**
 * 
 */
package com.demo2do.strawberry.entity.startup.fund;

/**
 * @author lute
 *
 */
public enum FundProgressType {
	
	/** 预约投资 */
	RESERVATION("enum.fund-progress-type.reservation", FundStatus.LATEST),
	
	/** 申请领投 */
	APPLICATION("enum.fund-progress-type.application", FundStatus.PREFUNDING),
	
	/** 参与合投 */
	PARTICIPATION("enum.fund-progress-type.participation", FundStatus.FUNDING);
	
	private String key;
	
	private FundStatus fundStatus;
	
	/**
	 * @param key
	 */
	private FundProgressType(String key, FundStatus fundStatus) {
		this.key = key;
		this.fundStatus = fundStatus;
	}
	
	/**
	 * @return the key
	 */
	public String getKey() {
		return key;
	}
	
	/**
	 * @return the fundStatus
	 */
	public FundStatus getFundStatus() {
		return fundStatus;
	}
	
	/**
	 * get the alias of fund progress type
	 * 
	 * @return
	 */
	public String getAlias() {
		return this.key.substring(key.lastIndexOf(".") + 1);
	}
	
	/**
	 * get the fund progress type according to fund status
	 * 
	 * @param value
	 * @return
	 */
	public static FundProgressType aliasOf(FundStatus fundStatus) {
		for(FundProgressType fundProgressType : FundProgressType.values()) {
			if(fundProgressType.getFundStatus().getAlias().equalsIgnoreCase(fundStatus.getAlias())) {
				return fundProgressType;
			}
		}
		return null;
	}
	
}
